<template>
  <el-space direction="vertical" alignment="flex-start">
    <el-skeleton style="width: 500px" :loading="loading" animated :count="3">
      <template #template>
        <el-skeleton-item variant="image" style="width: 250px; height: 150px" />
        <el-skeleton-item variant="text" style="margin-right: 16px" />
        <el-skeleton-item variant="text" style="width: 30%" />
        <div style="padding: 14px">
          <el-skeleton-item variant="h3" style="width: 50%" />
          <div
            style="
              display: flex;
              align-items: center;
              justify-items: space-between;
              margin-top: 16px;
              height: 16px;
            "
          >
            <el-skeleton-item variant="text" style="margin-right: 16px" />
            <el-skeleton-item variant="text" style="width: 30%" />
          </div>
        </div>
      </template>
      <template #default>
        <el-card
          v-for="item in lists"
          :key="item.name"
          :body-style="{ padding: '10px', marginBottom: '1px' }"
        >
          <div
            style="
              display: flex;
              align-items: center;
              justify-items: space-between;
              margin-top: 16px;
              margin-bottom: 16px;
            "
          >
            <img :src="item.imgUrl" class="image multi-content" />
            <div style="padding: 30px">
              <span>{{ item.name }}</span>
              <div class="bottom card-header">
                <div class="time">{{ item.refs }}</div>
              </div>
            </div>
          </div>

          <hr />
          <div style="padding: 14px">
            <span>上次登录地点：{{ item.name }}</span>
            <div class="bottom card-header">
              <div class="time">上次登录时间：{{ currentDate }}</div>
            </div>
          </div>
        </el-card>
      </template>
    </el-skeleton>
  </el-space>
</template>

<script lang="ts" setup>
import { onMounted, ref } from "vue";

interface ListItem {
  imgUrl: string;
  name: string;
  refs: string;
}

const loading = ref(true);
const lists = ref<ListItem[]>([]);
const currentDate = new Date().toDateString();

// const setLoading = () => {
//   loading.value = true;
//   setTimeout(() => {
//     loading.value = false;
//   }, 2000);
// };

onMounted(() => {
  loading.value = false;
  lists.value = [
    {
      imgUrl:
        "https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg",
      name: "Admin",
      refs: "管理员",
    },
  ];
});
</script>

<style scoped lang="scss">
.breadcrumb {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.homeuser {
  background: rgb(255, 255, 255);
}
.image {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  margin-left: 20px;
}

.el-card.is-always-shadow {
  width: 450px;
  margin: 20px 20px 0 20px;
}
</style>
